package com.donquijote.spring14real.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Component;

/**
 * @author 421527548@qq.com
 * @version V1.0
 * @title
 * @description
 * @date 2022-11-29 19:24
 */
@Component("affairAspect")
@Aspect
public class AffairAspect {

    @Around("execution(* com.donquijote.spring14real.service.BankService.*(..))")
    public void bankAround(ProceedingJoinPoint joinPoint)  {
        try {
            //前环绕
            System.out.println("开启事务");

            joinPoint.proceed();
            //后环绕
            System.out.println("关闭事务");
        }catch (Throwable e){
            e.printStackTrace();
            //回滚事务
            System.out.println("回滚事务");
        }
    }


}
